/*
 * @Author: 缄默
 * @Date: 2021-12-12 15:18:16
 * @LastEditors: 缄默
 * @LastEditTime: 2021-12-14 10:04:00
 */

//代理模式

#include <iostream>

using namespace std;

class Subject {
public:
    virtual void request() = 0;
    virtual ~Subject() { }
};

class ConcreteSubject : public Subject {
public:
    void request() {
        cout << " ConcreteSubject::request..." << endl;
    }
};

class Proxy : public Subject {
private:
    Subject* _sub;

public:
    Proxy(Subject* sub) {
        _sub = sub;
    }

    void request() {
        _sub->request();
    }
};

int main() {
    Subject* sub = new ConcreteSubject();
    Proxy* pro = new Proxy(sub);
    pro->request();

    delete sub;
    delete pro;
    
    return 0;
}
